package JVM;

import java.text.MessageFormat;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * @Author zhangxuhui
 * @Date 2023/12/24
 * @email zxh_1633@163.com
 */
public class cpu {
    private static final Logger LOGGER = Logger.getLogger(cpu.class.getName());
    /**
     * 主方法是Java程序的入口点。
     *
     * @param args 命令行参数
     */
    public static void main(String[] args) {

        String pattern = "I am {0}. I have {1} cats and {2} dogs";
        String message = MessageFormat.format(pattern, "Peter", 3, 2);
        System.out.println(message);

        Runtime runtime = Runtime.getRuntime();

        // 检查Runtime是否为null
        if (runtime == null) {
            LOGGER.log(Level.SEVERE, "Unable to get Runtime object.");
            return;
        }

        int processors = runtime.availableProcessors();
        // 使用日志记录处理器数量
        LOGGER.log(Level.INFO, "Number of processors: {0}", processors);
    }

}
